<!DOCTYPE HTML>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <style>body{ background-image: url('/upload/2.jpg'); background:no-repeat; }</style>
    <title>视频分类</title></head>
  <body>
    <table>
      <tr>
        <td></td>
      </tr>
    </table>
    <table class="table">
      <tr>
        <td class="va-t">
          <ul id="treeDemo" class="ztree"></ul>
        </td>
        <td class="va-t">
          <iframe ID="testIframe" Name="testIframe" FRAMEBORDER=0 SCROLLING=AUTO width=100% height=390px SRC="/cate/create"></iframe>
        </td>
      </tr>
    </table>
    <script type="text/javascript" src="/admins/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
    <script type="text/javascript">var setting = {
        view: {
          dblClickExpand: false,
          showLine: false,
          selectedMulti: false
        },
        data: {
          simpleData: {
            enable: true,
            idKey: "id",
            pIdKey: "pId",
            rootPId: ""
          }
        },
        callback: {
          beforeClick: function(treeId, treeNode) {
            var zTree = $.fn.zTree.getZTreeObj("tree");
            if (treeNode.isParent) {
              zTree.expandNode(treeNode);
              return false;
            } else {
              demoIframe.attr("src", treeNode.file + ".html");
              return true;
            }
          }
        }
      };
      // 遍历出来显示的信息
      var zNodes = [@foreach($cates as $cate) {
        id: {
          {
            $cate - >id
          }
        },
        pId: {
          {
            $cate - >pid
          }
        },
        name: "{{$cate->name}}"
      },
      @endforeach]
      var code;

      function showCode(str) {
        if (!code) code = $("#code");
        code.empty();
        code.append("<li>" + str + "</li>");
      }

      $(document).ready(function() {
        var t = $("#treeDemo");
        t = $.fn.zTree.init(t, setting, zNodes);
        demoIframe = $("#testIframe");
        //demoIframe.on("load", loadReady);
        var zTree = $.fn.zTree.getZTreeObj("tree");
        //zTree.selectNode(zTree.getNodeByParam("id",'11'));
      });</script>
  </body>
</html>